﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="dialog_products_attribute.aspx.cs" Inherits="Donal.Xms.Web.qianyi.dialog.dialog_products_attribute" %>

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <title>类别规格</title>
    <link rel="stylesheet" type="text/css" href="../skin/icon/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../skin/default/style.css" />
    <script type="text/javascript" charset="utf-8" src="../../scripts/jquery/jquery-1.11.2.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="../js/common.js"></script>
    <script type="text/javascript">
        var api = top.dialog.get(window);; //获取父窗体对象
        $(function () {
            //设置窗口按钮及事件
            api.button([{
                value: '确定',
                callback: function () {                 
                    appendSpecHtml();
                },
                autofocus: true
            }, {
                value: '取消',
                callback: function () { }
            }
            ]);

            //设置按钮事件
            $(".spec-item li a").click(function () {
                if ($(this).parent().hasClass("selected")) {
                    $(this).parent().removeClass("selected");
                } else {
                    $(this).parent().addClass("selected");
                }
            });

            //初始化已选择的规格
            $(api.data).find("input[name='hid_field_id']").each(function () {
                var hideId = $(this).val();
                $(".spec-item li").each(function () {
                    if (!$(this).hasClass("selected") && $(this).attr("id") == hideId) {
                        $(this).addClass("selected");
                    }
                });
            });
        });

        //插入规格节点
        function appendSpecHtml() {
            $(api.data).empty();
            $(".spec-item li").each(function () {
                if ($(this).hasClass("selected")) {
                    execSpecHtml($(this).attr("title"), $(this).attr("id"));
                }
            });
        }

        //创建品牌的HTML
        function execSpecHtml(title, field_id) {
            let liHtml = "<tr class=\"td_c\"><td><input type=\"hidden\" name=\"hid_id\" id=\"hid_id\" value=\"0\" /><input type=\"hidden\" name=\"hid_field_id\" id=\"hid_field_id\" value=\"" + field_id + "\" /><span class=\"item_title\">" + title + "</span></td><td><input type=\"checkbox\" name=\"cbDisplay\" checked=\"checked\"  onclick=\"changeVale(this);\" /><input type=\"hidden\" name=\"hid_display\" value=\"0\" /></td><td><input type=\"number\" class=\"input small\" datatype=\"n\" value=\"99\" name=\"sort_id\" /></td><td><a title=\"删除\" class=\"img-btn\" onclick=\"delItemTr(this);\"><i class=\"iconfont icon-delete\"></i></a></td></tr>";


            $(api.data).append(liHtml);
        }

    </script>
</head>

<body>
    <form id="form1" runat="server">
        <div style="width: 500px; height: 280px; overflow: auto;">
            <div class="div-content">
                <dl>
                    <dt>规格列表</dt>
                    <dd>
                        <ul class="spec-item">
                            <asp:Repeater ID="rptList" runat="server">
                                <ItemTemplate>
                                    <li title="<%#Eval("title")%>" id="<%#Eval("id")%>">
                                        <a href="javascript:;"><%#Eval("title")%></a>
                                    </li>
                                </ItemTemplate>
                            </asp:Repeater>
                        </ul>
                    </dd>
                </dl>
            </div>
        </div>
    </form>
</body>
</html>
